home *** CD-ROM | disk | FTP | other *** search
/ 1,000+ Great Games / 1_1000 Games.iso / HERETIC / WARM15.ZIP / DMGLOBAL.I < prev    next >
Encoding:
Text File  |  1995-11-19  |  8.2 KB  |  315 lines

  1. /******************************************************************************
  2.     INCLUDE:    DMGLOBAL.I
  3.     WRITTEN BY:    Robert Fenske, Jr. (rfenske@swri.edu)
  4.                 Southwest Research Institute
  5.                 Electromagnetics Division
  6.                 6220 Culebra
  7.                 San Antonio, Texas 78238-5166
  8.     CREATED:    Mar. 1994
  9.     DESCRIPTION:    This include file contains all the necessary constant,
  10.             macro, syntax, and type definitions as well as all
  11.             external and global variables needed for the various
  12.             DOOM and HEXEN-related utility programs.
  13.  
  14.             DOOM is a trademark of id Software, Inc.
  15.             HEXEN is a trademark of Raven Software.
  16. ******************************************************************************/
  17. #if !defined(DM_Globals)
  18.  
  19. #undef ANSI_C
  20. #if defined(__STDC__) || defined(__STRICT_ANSI__) || defined(__OS2__)
  21. #define ANSI_C        1
  22. #endif
  23.  
  24. #if !defined(__OS2__)
  25. #define _Optlink
  26. #endif
  27.  
  28. /*===========================================================================*/
  29.  
  30. #define bcase        break;case        /* for a more reasonabble */
  31. #define bdefault    break;default        /* switch statement       */
  32. #define global                    /* global declarations */
  33. #define forward        extern            /* forward references */
  34. #define local        static            /* local declarations */
  35. #define otherwise    break;default        /* alternate default case */
  36. #define repeat        do
  37. #define until(expr)    while (!(expr))        /* for do ... until loops */
  38.  
  39. /*===========================================================================*/
  40.  
  41. typedef unsigned short    ushort;
  42. typedef unsigned int    boolean;        /* integer used as boolean */
  43. typedef short        word;            /* 16-bit word */
  44. typedef word        bams;            /* 16-bit bams */
  45.  
  46. /*===========================================================================*/
  47.  
  48. #undef PI
  49. #define PI        (double)3.14159265358979323846    /* ubiquitous PI */
  50. #define TWOPI        (double)6.28318530717958647693
  51. #define bams_to_deg    (double)0.00549316406250000000    /* angle conv consts */
  52. #define deg_to_bams   (double)182.04444444444444444444
  53. #define bams_to_rad    (double)0.00009587379924285258
  54. #define rad_to_bams (double)10430.37835047045272494957
  55. #define deg_to_rad    (double)0.01745329251994329577
  56. #define rad_to_deg     (double)57.29577951308232087680
  57. #define BAMS180        ((bams)0x8000)        /* BAMS: (-)180 degrees */
  58. #define BAMS090        ((bams)0x4000)        /* BAMS: 90 degrees */
  59.  
  60. #define FALSE        0
  61. #define TRUE        (!FALSE)
  62.  
  63. /*===========================================================================*/
  64. #if !defined(__OS2__)
  65. #define abs(a)        ((a) < 0 ? -(a) : (a))
  66. #define min(a,b)    ((a) < (b) ? (a) : (b))
  67. #define max(a,b)    ((a) < (b) ? (b) : (a))
  68. #endif
  69. #define numbits(v)    (8*numbytes(v))
  70. #define numbytes(v)    ((unsigned)sizeof(v))
  71. #define numelm(a)    (sizeof a / sizeof a[0])
  72. #define sgn(a)        ((0<(a))-((a)<0))
  73.  
  74.     /* the blockmem() routine must allocate and MUST zero memory */
  75. #define blockmem(t,n)    (t *)(0<(n)?calloc((unsigned)(n),sizeof(t)):NULL)
  76. #if defined(__OS2__)
  77. #include <string.h>
  78. #define blockfree(b)    (free((char *)(b)))
  79. #elif defined(sun)
  80. #define blockfree(b)    ((b)!=NULL?free((char *)(b)):0)
  81. #else
  82. #define blockfree(b)    ((b)!=NULL?free((char *)(b)):(void)0)
  83. #endif
  84. #define blockcopy(bt,bf,n) (void)memcpy((char *)(bt),(char *)(bf),(int)(n))
  85.  
  86. /*===========================================================================*/
  87.  
  88. typedef struct DOOM_THING {            /* DOOM thing information */
  89.     short x, y;
  90.     short angle;
  91.     short item;
  92.     short flag;
  93. } DOOM_THING;
  94.  
  95. typedef struct HEXEN_THING {            /* HEXEN thing information */
  96.     short id;
  97.     short x, y;
  98.     short z;
  99.     short angle;
  100.     short item;
  101.     short flag;
  102.     unsigned char special;
  103.     char specarg[5];
  104. } HEXEN_THING;
  105.  
  106. typedef HEXEN_THING WAD_THING;            /* thing information */
  107.  
  108. typedef struct DOOM_LINE {            /* DOOM line information */
  109.     short fndx, tndx;
  110.     short flag, action_flag;
  111.     short sect_tag;
  112.     short rsidndx, lsidndx;
  113. } DOOM_LINE;
  114.  
  115. typedef struct HEXEN_LINE {            /* HEXEN line information */
  116.     short fndx, tndx;
  117.     short flag;
  118.     unsigned char special;
  119.     char specarg[5];
  120.     short rsidndx, lsidndx;
  121. } HEXEN_LINE;
  122.  
  123. typedef struct WAD_LINE {            /* line information */
  124.     short fndx, tndx;
  125.     short flag, action_flag;
  126.     short sect_tag;
  127.     unsigned char special;
  128.     char specarg[5];
  129.     short rsidndx, lsidndx;
  130. } WAD_LINE;
  131.  
  132. typedef struct WAD_SIDE {            /* side information */
  133.     short image_xoff, image_yoff;
  134.     char lwall[8], uwall[8], nwall[8];
  135.     short sectndx;
  136. } WAD_SIDE;
  137.  
  138. typedef struct WAD_VERT {            /* vertex information */
  139.     short x, y;
  140. } WAD_VERT;
  141.  
  142. typedef struct WAD_SEGS {            /* segment information */
  143.     short fndx, tndx;
  144.     bams angle;
  145.     short lndx;
  146.     short sndx;
  147.     short loffset;
  148. } WAD_SEGS;
  149.  
  150. typedef struct WAD_SSECTOR {            /* subsector information */
  151.     short count;
  152.     short sndx;
  153. } WAD_SSECTOR;
  154.  
  155. typedef struct WAD_NODE {            /* node information */
  156.     short x, y;
  157.     short xdel, ydel;
  158.     short rymax, rymin, rxmin, rxmax;
  159.     short lymax, lymin, lxmin, lxmax;
  160.     short nndx[2];
  161. } WAD_NODE;
  162.  
  163. typedef struct WAD_SECTOR {            /* sector information */
  164.     short floor_ht, ceil_ht;
  165.     char floor_desc[8], ceil_desc[8];
  166.     short light_lvl;
  167.     short property;
  168.     short line_tag;
  169. } WAD_SECTOR;
  170.  
  171. typedef unsigned char    WAD_REJECT;        /* reject information */
  172.  
  173. typedef short        WAD_BLOCKMAP;        /* blockmap information */
  174.  
  175. typedef unsigned char    WAD_BEHAVIOR;        /* behavior information */
  176.  
  177. /*===========================================================================*/
  178.  
  179. #define MAINS        0            /* a level's resources */
  180. #define THINGS        1
  181. #define LINES        2
  182. #define SIDES        3
  183. #define VERTS        4
  184. #define SEGS        5
  185. #define SSECTS        6
  186. #define NODES        7
  187. #define SECTS        8
  188. #define REJECTS        9
  189. #define BLKMAPS        10
  190. #define BEHAVS        11            /* Hexen only */
  191. #define ALL(t)        ((t)==HEXEN_FILE?12:11)    /* always last */
  192.  
  193. #define RG_REJDEPTH    (7<<0)            /* reject depth (0 - 7) */
  194. #define RG_UNIQSECT    (1<<3)            /* nodes: unique sector mode */
  195. #define RG_USEALL    (1<<4)            /* nodes: use all segs */
  196. #define RG_LIMIT_IO    (1<<5)            /* limit screen I/O */
  197.  
  198. #define DOOM_FILE    1            /* input/output file types */
  199. #define HEXEN_FILE    2
  200. #define PATCH_FILE    3
  201.  
  202. typedef struct WAD_HEAD {            /* WAD file header */
  203.     char ident[4];
  204.     long count;
  205.     long offset;
  206. } WAD_HEAD;
  207.  
  208. typedef struct DIR_ENTRY {            /* WAD file directory entry */
  209.     long offset;
  210.     long nbytes;
  211.     char name[8];
  212. } DIR_ENTRY;
  213.  
  214. typedef struct WAD_INFO {            /* WAD file information */
  215.     FILE *fp;                    /* file pointer */
  216.     int type;                    /* (I/P)WAD,patch */
  217.     WAD_HEAD head;                    /* file header */
  218.     DIR_ENTRY *origdir,                /* orig directory */
  219.               *dir;                    /* resources dirctry */
  220.     char **data;                    /* resources data */
  221.     boolean *changed;                /* rsrce changed flg */
  222.     long *count;                    /* resources size */
  223.     int ep, mp;                    /* cur episode/map */
  224.     double ver;                    /* patch version */
  225. } WAD_INFO;
  226.  
  227. /*===========================================================================*/
  228.  
  229. extern void resource_update(
  230. #if defined(ANSI_C)
  231.     WAD_INFO *winfo,
  232.     int entry,
  233.     void *data,
  234.     long count
  235. #endif
  236. );
  237. extern boolean patch_read(
  238. #if defined(ANSI_C)
  239.     WAD_INFO *winfo,
  240.     int entry,
  241.     long resources_needed
  242. #endif
  243. );
  244. extern boolean patch_write(
  245. #if defined(ANSI_C)
  246.     WAD_INFO *oinfo,
  247.     WAD_INFO *winfo
  248. #endif
  249. );
  250. extern WAD_INFO *wad_open(
  251. #if defined(ANSI_C)
  252.     char *file,
  253.     boolean input,
  254.     boolean rewrite
  255. #endif
  256. );
  257. extern boolean wad_read(
  258. #if defined(ANSI_C)
  259.     WAD_INFO *winfo,
  260.     int entry,
  261.     long resources_needed
  262. #endif
  263. );
  264. extern boolean wad_write(
  265. #if defined(ANSI_C)
  266.     WAD_INFO *oinfo,
  267.     WAD_INFO *winfo
  268. #endif
  269. );
  270. extern void wad_close(
  271. #if defined(ANSI_C)
  272.     WAD_INFO *winfo
  273. #endif
  274. );
  275.  
  276. extern long nodes_make(                /* makes NODES,SSECTORS,SEGS */
  277. #if defined(ANSI_C)
  278.     WAD_NODE **nodes,
  279.     long *nnodes,
  280.     WAD_SSECTOR **ssecs,
  281.     long *nssecs,
  282.     WAD_SEGS **segs,
  283.     long *nsegs,
  284.     WAD_VERT **verts,
  285.     long *nverts,
  286.     WAD_LINE **lines,
  287.     long *nlines,
  288.     WAD_SIDE **sides,
  289.     int genflags
  290. #endif
  291. );
  292. extern long blockmap_make(            /* makes the BLOCKMAP */
  293. #if defined(ANSI_C)
  294.     register short **blockmap,
  295.     register WAD_LINE *lines,
  296.     long nlines,
  297.     WAD_VERT *verts
  298. #endif
  299. );
  300. extern long reject_make(            /* makes REJECT */
  301. #if defined(ANSI_C)
  302.     WAD_REJECT **reject,
  303.     int rej_flags,
  304.     char *except,
  305.     WAD_LINE *lines,
  306.     long nlines,
  307.     WAD_SIDE *sides,
  308.     WAD_VERT *verts,
  309.     WAD_BLOCKMAP *blockmap
  310. #endif
  311. );
  312.  
  313. #define DM_Globals    1            /* now have defined these */
  314. #endif
  315.